var SCRIBEFIRE_PUBOPT = {
	prefs : null,
	
	opener : function () {
		if (opener.wrappedJSObject) {
			return opener.wrappedJSObject;
		}

		return opener;
	},

	load : function (supportForSlugs) {
		document.getElementById("slug").value = '';
		document.getElementById("edit-or-new").selectedItem = document.getElementById("publish-new-post");
		
		this.prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService)
			.getBranch("performancing.");

		document.getElementById("draft-checkbox").hidden = !pffEditorUI.parentWindow.SCRIBEFIRE_BLOG.supportsDrafts;
		document.getElementById("draft-checkbox").checked = pffEditorUI.isDraft || this.prefs.getBoolPref("publish.checkdraft");

		if (pffEditorUI.parentWindow.SCRIBEFIRE_BLOG.supportsPages) {
			document.getElementById("publish-page").disabled = false;
		}

		if (pffEditorUI.entryId && pffEditorUI.type != 'note' && pffEditorUI.type != "") {
			document.getElementById("publish-edit").disabled = false;
		}

		if (pffEditorUI.type == 'page') {
			document.getElementById("edit-or-new").selectedIndex = 2;
		}

		if (supportForSlugs) {
		    document.getElementById("slug").value = pffEditorUI.slug;
		}
		else {
		    document.getElementById("slug-container").style.display = "none";
		}
		
		document.getElementById("editor-container").style.display = 'none';
		document.getElementById("publishing-options").style.display = '';
	},

	cancel : function () {
		// Just hide this panel.
		document.getElementById("editor-container").style.display = '';
		document.getElementById("publishing-options").style.display = 'none';
	},

	accept : function () {
		var val = 'post';

		if (document.getElementById("publish-edit").selected) {
			val = 'edit';
		}
		else {
			if (document.getElementById('publish-page').selected) {
				val = 'page';
			}
		}
		
		document.getElementById("editor-container").style.display = '';
		document.getElementById("publishing-options").style.display = 'none';
		
		pffEditorUI.parentWindow.gPerformancingUtil.publish({isEdit: (val == 'edit'), isPage:(val == 'page'), draft:document.getElementById("draft-checkbox").checked, slug:document.getElementById("slug").value}); 
	}
};